<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class LuckSet extends Model{

    const CREATED_AT = 'create_time'; // 创建时间
    const UPDATED_AT = 'update_time'; // 开始时间

    protected $table="luck_set"; // 数据库表
    protected $dateFormat = 'U'; // 时间戳

    /**
     * 搜索幸运值设置
     *
     * @author RJ
     * @time 2018.02.03
     * @param  int  $state 状态 1:签到 2:发红包 3:领红包
     * @return array $score 幸运值
     */
    public static function getLuckScore($state = 1){
        $LuckSet = new LuckSet(); // 实例化对象
        $luck_set = $LuckSet
            ->select('name', 'score')
            ->where(function($query)use($state){
                $query -> where('state',$state);
            })
            ->first();
        $score_info = $luck_set->toArray();
        return $score_info;
    }

}
